package com.nf.xiaomi.web.controller;

import com.nf.mvc.ViewResult;
import com.nf.mvc.mapping.RequestMapping;
import com.nf.mvc.support.ResponseVO;
import com.nf.xiaomi.entity.OrderEntity;
import com.nf.xiaomi.service.OrderDetailService;
import com.nf.xiaomi.service.impl.OrderDetailServiceImpl;

import java.util.List;

import static com.nf.mvc.handler.HandlerHelper.json;

@RequestMapping("/orderDetail")
public class OrderDetailController {
    OrderDetailService orderService = new OrderDetailServiceImpl();

    @RequestMapping("/getAll")
    public ViewResult getAll() {
        List<OrderEntity> list = orderService.getAll();
        return json(new ResponseVO(200, "ok", list));
    }

    @RequestMapping("/getAllState")
    public ViewResult getAll(Integer orderState) {
        List<OrderEntity> list = orderService.getAll(orderState);
        return json(new ResponseVO(200, "ok", list));
    }

    @RequestMapping("/getAllAccount")
    public ViewResult getAll(Long account) {
        List<OrderEntity> list = orderService.getAll(account);
        return json(new ResponseVO(200, "ok", list));
    }

    @RequestMapping("/confirmOrder")
    public ViewResult getConfirmOrder(Long account,Integer orderID) {
        List<OrderEntity> list = orderService.confirmOrder(account, orderID);
        return json(new ResponseVO(200, "ok", list));
    }
}
